<!--
 * @Descripttion: 
 * @version: 
 * @Author: ada.wu
 * @Date: 2025-06-25 23:48:14
 * @LastEditors: ada.wu
 * @LastEditTime: 2025-07-09 21:48:56
-->
<style>
    .top-panel>.layui-card-body {
        height: 130px;
    }

    .date-input {
        width: 200px;
    }
</style>
<div class="layuimini-container layuimini-page-anim">
    <!-- 用于创建子页面 -->
    <div class="page-create"></div>

    <!-- page-main-create -->
    <!-- 用于显示 隐藏 -->
    <div class="layuimini-main page-main-create">
        <div class="layuimini-title">
            <div class="flex items-center">
                <h4><span>车辆离线报表</span></h4>
                <input type="text" name="datePeriodStart" autocomplete="off" id="date_period"
                    class="layui-input date-input ml-3" placeholder="请选择" />
            </div>
        </div>
        <div class="m-df">
            <form class="layui-form" action="" lay-filter="search-form">
                <div class="layui-form-item">
                    <div class="search-box-wrapper">
                        <div class="search-box-body">
                            <div class="layui-inline">
                                <label class="layui-form-label">车牌号</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="name" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属组织</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="businessNames" lay-search>
                                        <option value="1">清扫保洁</option>
                                        <option value="2">绿化养护</option>
                                        <option value="3">设施维护</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">关联网格</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="businessNames" lay-search>
                                        <option value="1">清扫保洁</option>
                                        <option value="2">绿化养护</option>
                                        <option value="3">设施维护</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">全天离线</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="businessNames" lay-search>
                                        <option value="1">清扫保洁</option>
                                        <option value="2">绿化养护</option>
                                        <option value="3">设施维护</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="search-box-btns">
                            <button type="submit" class="layui-btn layui-btn-sm" lay-submit
                                lay-filter="data-search-btn">查询</button>
                            <button type="reset" class="layui-btn  layui-btn-sm layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
     

        <div class="px-5  table-stripe">
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </div>
        <script type="text/html" id="currentTableBar">
            <a class="layui-font-blue mr-3" lay-event="detail">详情</a>
        </script>
    </div>
</div>
<script>
    layui.use(['form', 'table', 'miniPage', 'echarts'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            layer = layui.layer,
            util = layui.util,
            echarts = layui.echarts,
            miniPage = layui.miniPage;
        /******************** 渲染组件 start ********************/
        form.render('select'); //刷新select选择框渲染
        // 起始日期
        laydate.render({
            elem: '#date_period',
            range: true
        });
        util.on('lay-on', {
            // 完成率
            'work_coverage': function () {
                console.log('完成率===')
                miniPage.renderPageCreate('page/laborOperations/laborWorkList/components/workDetail.html')
            },
            //覆盖率
            'work_completion': function () {
                console.log('覆盖率==')
                // miniPage.renderPageCreate('page/laborOperations/laborJobManager/components/map.html')
                miniPage.renderPageCreate('page/laborOperations/laborWorkList/components/workDetail.html')
            }
        })


        /******************** 渲染组件 end ********************/



        table.render({
            elem: '#currentTableId',
            url: 'api/table.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter'],
            cols: [[
                { field: 'name', minWidth: 120, title: '车辆' },
                { field: 'score', minWidth: 120, title: '车辆状态', sort: true },
                { field: 'score', minWidth: 120, title: '在线（天）' },
                { field: 'score', minWidth: 140, title: '全天离线（天）' },
                { field: 'score', minWidth: 120, title: '在线率', sort: true },
                { field: 'score', minWidth: 140, title: '在线时长（h）', sort: true },
                { field: 'score', minWidth: 140, title: '行驶里程（km）' },
                { field: 'score', minWidth: 100, title: '所属项目' },
                { field: 'score', minWidth: 100, title: '所属组织' },
                { field: 'score', minWidth: 100, title: '业务类型' },
                { field: 'score', minWidth: 100, title: '关联网络' },
                { title: '操作', minWidth: 100, toolbar: '#currentTableBar', align: "center" }
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            size: 'lg'
        });
          table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
          if (obj.event === 'detail') {  // 监听详情操作
            
            //新增传值
                layui.sessionData('CAR_WORK_OFFLINE_PARAMS', {
                    key: 'dataDto',
                    value: JSON.stringify(data)
                });
                miniPage.renderPageCreate(`page/mechanicalWork/carWorkOfflineList/components/carWorkOfflineDetail.html`)
            }
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar事件监听
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {   // 监听添加操作
                var content = miniPage.getHrefContent('page/table/add.html');
                var openWH = miniPage.getOpenWidthHeight();

                var index = layer.open({
                    title: '添加用户',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
        });
    });



</script>